package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * 增强型for循环：
 */

public class NewForDemo {
    public static void main(String[] args) {
        String[] str={"one","two","three","four","five"};
        for (int i=0;i<str.length;i++){
            System.out.println(str[i]);
        }

        for (String s:str){
            System.out.println(s);
        }

        Collection c=new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        Iterator it=c.iterator();//生成一个迭代器
        while (it.hasNext()){
            String s=(String) it.next();
            System.out.println(s);
        }

        for (Object obj:c){
            String str1=(String) obj;
            System.out.println(str1);
        }

    }
}
